#!/usr/bin/env python3
# coding:utf-8

import time
import paho.mqtt.client as mqtt

def on_connect(client,userdata,flags,rc):
    print("Connected with result code "+str(rc))
    
def on_message(client,userdata,msg):
    print("Received message '"+str(msg.payload)+"' on topic '"+msg.topic+"' with QoS "+str(msg.qos))
    
client =  mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.connect("localhost",1883,200)

client.publish("test/aaa",payload="Hello World!",qos=0)
# time.sleep(0.5)
client.publish("test/bbb",payload="I am bbb",qos=0)
# time.sleep(0.5)
client.publish("test/ccc",payload="I am ccc",qos=1)
